//
//  ImgeUtils.swift
//  CHSimpleUI
//
//  Created by cyptt on 2023/6/25.
//

import UIKit

public class CHImageUtils: NSObject {

    /*
     base64 转译成data
     */
    public static func base64TransData(base64:String?)->Data?{
        if base64 == nil {
            return nil
        }
        let data:Data? = Data(base64Encoded: base64!,options: Data.Base64DecodingOptions.init(rawValue: 0))
        return data
    }
    
    /*
     base64 转成图片UIImage
     */
    public static func base64TransImage(base64:String?)->UIImage?{
        if base64 == nil {
            return nil
        }
        let data:Data? = self.base64TransData(base64: base64!)
        if data != nil{
            let image:UIImage? = UIImage(data: data!)
            return image
        }else{
            return nil
        }
     
    }
}
